using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_Blog_Tmp {
		#region Fields
		private int iD;
		private string blog_title;
		private string blog_content;
		private int blog_type;
		private string blog_note;
		private DateTime keyin_date = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private int owner_id;
		private int reader_count;
		private int comment_count;
		private string public_type;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_Blog_Tmp class.
		/// </summary>
		public TF_Blog_Tmp() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Blog_Tmp class.
		/// </summary>
		public TF_Blog_Tmp(string blog_title, string blog_content, int blog_type, string blog_note, DateTime keyin_date, int owner_id, int reader_count, int comment_count, string public_type) {
			this.blog_title = blog_title;
			this.blog_content = blog_content;
			this.blog_type = blog_type;
			this.blog_note = blog_note;
			this.keyin_date = keyin_date;
			this.owner_id = owner_id;
			this.reader_count = reader_count;
			this.comment_count = comment_count;
			this.public_type = public_type;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Blog_Tmp class.
		/// </summary>
		public TF_Blog_Tmp(int iD, string blog_title, string blog_content, int blog_type, string blog_note, DateTime keyin_date, int owner_id, int reader_count, int comment_count, string public_type) {
			this.iD = iD;
			this.blog_title = blog_title;
			this.blog_content = blog_content;
			this.blog_type = blog_type;
			this.blog_note = blog_note;
			this.keyin_date = keyin_date;
			this.owner_id = owner_id;
			this.reader_count = reader_count;
			this.comment_count = comment_count;
			this.public_type = public_type;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the Blog_title value.
		/// </summary>
		public string Blog_title {
			get { return blog_title; }
			set { blog_title = value; }
		}
		
		/// <summary>
		/// Gets or sets the Blog_content value.
		/// </summary>
		public string Blog_content {
			get { return blog_content; }
			set { blog_content = value; }
		}
		
		/// <summary>
		/// Gets or sets the Blog_type value.
		/// </summary>
		public int Blog_type {
			get { return blog_type; }
			set { blog_type = value; }
		}
		
		/// <summary>
		/// Gets or sets the Blog_note value.
		/// </summary>
		public string Blog_note {
			get { return blog_note; }
			set { blog_note = value; }
		}
		
		/// <summary>
		/// Gets or sets the Keyin_date value.
		/// </summary>
		public DateTime Keyin_date {
			get { return keyin_date; }
			set { keyin_date = value; }
		}
		
		/// <summary>
		/// Gets or sets the Owner_id value.
		/// </summary>
		public int Owner_id {
			get { return owner_id; }
			set { owner_id = value; }
		}
		
		/// <summary>
		/// Gets or sets the Reader_count value.
		/// </summary>
		public int Reader_count {
			get { return reader_count; }
			set { reader_count = value; }
		}
		
		/// <summary>
		/// Gets or sets the Comment_count value.
		/// </summary>
		public int Comment_count {
			get { return comment_count; }
			set { comment_count = value; }
		}
		
		/// <summary>
		/// Gets or sets the Public_type value.
		/// </summary>
		public string Public_type {
			get { return public_type; }
			set { public_type = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_Blog_Tmp table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_Blog_TmpInsert", blog_title, blog_content, blog_type, blog_note, keyin_date, owner_id, reader_count, comment_count, public_type));
		}
		
		/// <summary>
		/// Updates a record in the TF_Blog_Tmp table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_Blog_TmpUpdate", iD, blog_title, blog_content, blog_type, blog_note, keyin_date, owner_id, reader_count, comment_count, public_type);
		}
		
		/// <summary>
		/// Deletes a record from the TF_Blog_Tmp table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_Blog_TmpDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_Blog_Tmp table.
		/// </summary>
		public static TF_Blog_Tmp Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_Blog_TmpSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_Blog_Tmp(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_Blog_Tmp table.
		/// </summary>
		public static List<TF_Blog_Tmp> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_Blog_TmpSelectAll")) {
				List<TF_Blog_Tmp> tF_Blog_TmpList = new List<TF_Blog_Tmp>();
				while (dataReader.Read()) {
					TF_Blog_Tmp tF_Blog_Tmp = MakeTF_Blog_Tmp(dataReader);
					tF_Blog_TmpList.Add(tF_Blog_Tmp);
				}
				return tF_Blog_TmpList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_Blog_Tmp class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_Blog_Tmp MakeTF_Blog_Tmp(SqlDataReader dataReader) {
			TF_Blog_Tmp tF_Blog_Tmp = new TF_Blog_Tmp();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_Blog_Tmp.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_Blog_Tmp.Blog_title = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_Blog_Tmp.Blog_content = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_Blog_Tmp.Blog_type = dataReader.GetInt32(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_Blog_Tmp.Blog_note = dataReader.GetString(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_Blog_Tmp.Keyin_date = dataReader.GetDateTime(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_Blog_Tmp.Owner_id = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_Blog_Tmp.Reader_count = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_Blog_Tmp.Comment_count = dataReader.GetInt32(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_Blog_Tmp.Public_type = dataReader.GetString(9);
			}

			return tF_Blog_Tmp;
		}
		#endregion
	}
}
